<template>
  <div class="app-container">
    <el-form  :model="form" :rules="rules" label-width="80px">
      <el-form-item label="商会名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入商会名称" />
      </el-form-item>
      <el-form-item label="商会简介" prop="introduction">
        <el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" />
      </el-form-item>
      <el-form-item label="商会章程" prop="charter">
        <el-input v-model="form.charter" type="textarea" placeholder="请输入内容" />
      </el-form-item>
      <el-form-item label="入会须知" prop="membershipGuide">
        <el-input v-model="form.membershipGuide" type="textarea" placeholder="请输入内容" />
      </el-form-item>
    </el-form>
  </div>
  <hr custom-hr>
  <div class="button01">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            @click="submitForm"
            v-hasPermi="['manager:chamber:add']"
        >保存</el-button>

      </el-col>
    </el-row>
  </div>

</template>

<script setup name="Chamber">
import {  addChamber, updateChamber } from "@/api/manager/chamber"

const { proxy } = getCurrentInstance()

const chamberList = ref([])

const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  rules: {
  }
})

const { queryParams, form, rules } = toRefs(data)

// 尝试以下导入方式之一
import useTagsViewStore from '@/store/modules/tagsView.js'
import router from '@/router/index'
const tagsViewStore = useTagsViewStore()

/** 提交按钮 */
function submitForm() {
        addChamber(form.value).then(response => {
          // 添加标签页
          tagsViewStore.addView({
            path: '/manager/chamber/addSuccesd',
            name: 'AddSuccess',
            meta: { title: '页面标题' }
          })

          // 跳转到该路由
          router.push('/manager/chamber/addSuccesd')
        })
}
/** 提交按钮 */
// function submitForm() {
//   addChamber(form.value).then(response => {
//     proxy.$modal.msgSuccess("新增成功")
//     // 把路由跳转放在成功回调里，保证新增成功后再跳转
//     this.$router.push({
//       path: '/views/manager/chamber/addSuccesd'
//     })
//   }).catch(error => {
//     // 建议添加错误处理逻辑
//     proxy.$modal.msgError("新增失败")
//   })
// }
</script>

<style scoped>
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.button01{
  display: flex;
  justify-content: center; /* 水平居中 */
  margin-top: 20px; /* 与表单的间距 */
  margin-bottom: 20px;
}
.custom-hr {
  margin-top: 100px; /* 水平线下移 */
  border: 0;
  border-top: 1px solid #eee;
}
</style>
